<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>增加</title>
    <link rel="stylesheet" href="/static/css/layui.css">

    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/static/css/diyUpload.css">
    <link rel="stylesheet" href="/static/css/webuploader.css">
</head>
<body>

<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">添加信息</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">添加内容</h4>
            </div>
            <div class="modal-body">
                <p>图片：
                    <div id="file"></div>
                <input type="hidden" id="img" value="">
                </p>
                <p>姓名：<input type="text" id="username"></p>
                <p>月薪：<input type="text" id="salary"></p>
                <p>单位：<input type="text" id="company"></p>
                <p>专业：<input type="text" id="professional"></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary add">增加提交</button>
            </div>
        </div>
    </div>
</div>
</body>
<script src="/static/js/jquery-3.1.1.min.js"></script>
<script src="/static/js/diyUpload.js"></script>
<script src="/static/js/webuploader.js"></script>

<script src="/static/js/layui.all.js"></script>
<script>
 $(function () {
     //图片上传
     $('#file').diyUpload({
        'url':'createAdd',
         success:function(data){
            $('#img').val(data);
             console.log(data);
         }
     })
     //异步提交数据
     $('.add').click(function () {
         var img=$('#img').val();
         var username=$('#username').val();
         var salary=$('#salary').val();
         var company=$('#company').val();
         var professional=$('#professional').val();
         console.log(img);
         console.log(username);
         console.log(salary);
         console.log(company);
         console.log(professional);
         $.post(
             'create',
             {
                 img:img,
                 username:username,
                 salary:salary,
                 company:company,
                 professional:professional,
             },
             function(data){
                 if (data.code==200){
                    alert('添加成功');
                    location.href='show';

                 }

             }
         )
     })

 })


</script>



</html>